/**
 * 
 */
package br.com.ufrn.aipetro.ga.domain.entity.interfaces;

import java.beans.PropertyChangeListener;
import java.beans.PropertyChangeSupport;

/**
 * @author Lucas
 *
 */
public abstract class AbstractModel implements Model {

	private PropertyChangeSupport propertyChangeSupport; 
	
	/**
	 * 
	 */
	public AbstractModel() {
		propertyChangeSupport = new PropertyChangeSupport(this);
	}
	
	/* (non-Javadoc)
	 * @see br.com.ufrn.aipetro.ga.domain.entity.interfaces.Model#addListener(java.beans.PropertyChangeListener)
	 */
	@Override
	public void addListener(PropertyChangeListener listener) {
		propertyChangeSupport.addPropertyChangeListener(listener);
	}

	/* (non-Javadoc)
	 * @see br.com.ufrn.aipetro.ga.domain.entity.interfaces.Model#removeListener(java.beans.PropertyChangeListener)
	 */
	@Override
	public void removeListener(PropertyChangeListener listener) {
		propertyChangeSupport.removePropertyChangeListener(listener);
	}
	
	/**
	 * @param propertyName
	 * @param oldValue
	 * @param newValue
	 */
	protected void firePropertyChange(String propertyName, Object oldValue, Object newValue) {
        propertyChangeSupport.firePropertyChange(propertyName, oldValue, newValue);
    }

}
